package com.wangys.controller;

import com.wangys.entities.Dfb;
import com.wangys.mapper.DfbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@ResponseBody
@CrossOrigin
@RequestMapping("/dfb")
public class DfdController {
    @Autowired(required = false)
    private DfbMapper dfbMapper;

    @RequestMapping("/select")
    public List<Dfb> select(){
        List<Dfb> list = dfbMapper.select();
        return list;
    }
    @RequestMapping("/add")
    public void add(Dfb dfb){
        dfbMapper.add(dfb);
    }
    @RequestMapping("/delete")
    public void delete(int id){
        dfbMapper.delete(id);
    }
    @RequestMapping("/byId")
    public Dfb byId(int id){
        return dfbMapper.byId(id);
    }
    @RequestMapping("/update")
    public void update(Dfb dfb){
        dfbMapper.update(dfb);
    }
    @RequestMapping("/deleteAll")
    public void deleteAll(String ids){
        String[] split = ids.split(",");
        List<Integer> arrayList=new ArrayList<Integer>();
        for ( String iid:split) {
            arrayList.add(Integer.parseInt(iid));
        }
        dfbMapper.deleteAll(arrayList);
    }
    @RequestMapping("/getCount")
    public List<Dfb> getCount(){
       return dfbMapper.getCount();
    }
    @RequestMapping("/like")
    public List<Dfb> like(Dfb dfb){
         return dfbMapper.like(dfb);
    }
    }

